<?php

/**
 * This is the model class for table "othersafetyfeatures".
 *
 * The followings are the available columns in table 'othersafetyfeatures':
 * @property integer $Id
 * @property integer $NoOfLubricantingBays
 * @property integer $NoOfWashRacks
 * @property integer $CrankcaseDrainageProvided
 * @property integer $OilOrWaterSeparatorProvided
 * @property integer $PerimeterOrFireWallProvided
 * @property double $Height
 * @property integer $AnyOpening
 * @property integer $DispensingPlatformProvided
 * @property integer $HeightWithinLimit
 * @property string $ManholeTankCoverMadeOf
 * @property double $Thickness
 * @property integer $Gasketed
 * @property integer $Housekeeping
 * @property integer $AnyRefreshmentStandBeingOperatedInsidePremises
 * @property integer $Establishment_Id
 *
 * The followings are the available model relations:
 * @property Establishments $establishment
 */
class Othersafetyfeatures extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'othersafetyfeatures';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NoOfLubricantingBays, NoOfWashRacks, CrankcaseDrainageProvided, OilOrWaterSeparatorProvided, PerimeterOrFireWallProvided, AnyOpening, DispensingPlatformProvided, HeightWithinLimit, Gasketed, Housekeeping, AnyRefreshmentStandBeingOperatedInsidePremises, Establishment_Id', 'numerical', 'integerOnly'=>true),
			array('Height, Thickness', 'numerical'),
			array('ManholeTankCoverMadeOf', 'length', 'max'=>60),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('Id, NoOfLubricantingBays, NoOfWashRacks, CrankcaseDrainageProvided, OilOrWaterSeparatorProvided, PerimeterOrFireWallProvided, Height, AnyOpening, DispensingPlatformProvided, HeightWithinLimit, ManholeTankCoverMadeOf, Thickness, Gasketed, Housekeeping, AnyRefreshmentStandBeingOperatedInsidePremises, Establishment_Id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'establishment' => array(self::BELONGS_TO, 'Establishments', 'Establishment_Id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'Id' => 'ID',
			'NoOfLubricantingBays' => 'No Of Lubricanting Bays',
			'NoOfWashRacks' => 'No Of Wash Racks',
			'CrankcaseDrainageProvided' => 'Crankcase Drainage Provided',
			'OilOrWaterSeparatorProvided' => 'Oil Or Water Separator Provided',
			'PerimeterOrFireWallProvided' => 'Perimeter Or Fire Wall Provided',
			'Height' => 'Height',
			'AnyOpening' => 'Any Opening',
			'DispensingPlatformProvided' => 'Dispensing Platform Provided',
			'HeightWithinLimit' => 'Height Within Limit',
			'ManholeTankCoverMadeOf' => 'Manhole Tank Cover Made Of',
			'Thickness' => 'Thickness',
			'Gasketed' => 'Gasketed',
			'Housekeeping' => 'Housekeeping',
			'AnyRefreshmentStandBeingOperatedInsidePremises' => 'Any Refreshment Stand Being Operated Inside Premises',
			'Establishment_Id' => 'Establishment',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('Id',$this->Id);
		$criteria->compare('NoOfLubricantingBays',$this->NoOfLubricantingBays);
		$criteria->compare('NoOfWashRacks',$this->NoOfWashRacks);
		$criteria->compare('CrankcaseDrainageProvided',$this->CrankcaseDrainageProvided);
		$criteria->compare('OilOrWaterSeparatorProvided',$this->OilOrWaterSeparatorProvided);
		$criteria->compare('PerimeterOrFireWallProvided',$this->PerimeterOrFireWallProvided);
		$criteria->compare('Height',$this->Height);
		$criteria->compare('AnyOpening',$this->AnyOpening);
		$criteria->compare('DispensingPlatformProvided',$this->DispensingPlatformProvided);
		$criteria->compare('HeightWithinLimit',$this->HeightWithinLimit);
		$criteria->compare('ManholeTankCoverMadeOf',$this->ManholeTankCoverMadeOf,true);
		$criteria->compare('Thickness',$this->Thickness);
		$criteria->compare('Gasketed',$this->Gasketed);
		$criteria->compare('Housekeeping',$this->Housekeeping);
		$criteria->compare('AnyRefreshmentStandBeingOperatedInsidePremises',$this->AnyRefreshmentStandBeingOperatedInsidePremises);
		$criteria->compare('Establishment_Id',$this->Establishment_Id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Othersafetyfeatures the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
